class RandomMatrix {
	double [][] data;
	int m, n;
	
	RandomMatrix(int m, int n) {
		this.m = m;
		this.n = n;
		data = new double[m][n];

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				data[i][j] = Math.random();
			}
		}
	}

	// 只保留两位小数 https://stackoverflow.com/questions/11701399/round-up-to-2-decimal-places-in-java
	static String roundOffTo2DecPlaces(double val) { 
	    return String.format("%.2f", val);
	}


	public String toString() {
		String rep = "";
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				rep += roundOffTo2DecPlaces(data[i][j]) + "\t";
			}
			rep += "\n";
			
		}		
		return rep;
	}

	static RandomMatrix add(RandomMatrix m1, RandomMatrix m2) {
		RandomMatrix sum = new RandomMatrix(m1.m, m1.n);
		for (int i = 0; i < sum.m; i++) {
			for (int j = 0; j < sum.n; j++) {
				sum.data[i][j] = m1.data[i][j] + m2.data[i][j];
			}
		}
		return sum;
	}
}

class Main {
	public static void main(String[] args) {
		System.out.println("hello");
		RandomMatrix m1 = new RandomMatrix(3,4);
		System.out.println(m1);
		System.out.println("--------------------------");
		RandomMatrix m2 = new RandomMatrix(3,4);
		System.out.println(m2);
		System.out.println("--------------------------");
		RandomMatrix sum = RandomMatrix.add(m1, m2);
		System.out.println(sum);
		
		
	}
}
